package cn.zct.domain.activity.service.trial.thread;
import cn.zct.domain.activity.adapter.repository.IActivityRepository;
import cn.zct.domain.activity.model.valobj.GroupBuyActivityDiscountVO;
import cn.zct.domain.activity.model.valobj.SCSkuActivityVO;

import javax.annotation.Resource;
import java.util.concurrent.Callable;

public class QueryGroupBuyActivityDiscountVOThreadTask implements Callable<GroupBuyActivityDiscountVO> {

    /**
     * 来源
     */
    private final String source;

    /**
     * 渠道
     */
    private final String channel;

    private final String goodsId;

    /**
     * 活动仓储
     */
    private final IActivityRepository repository;

    public QueryGroupBuyActivityDiscountVOThreadTask(String source, String channel, String goodsId,IActivityRepository repository) {
        this.source = source;
        this.channel = channel;
        this.repository = repository;
        this.goodsId = goodsId;
    }


    @Override
    public GroupBuyActivityDiscountVO call() throws Exception {
        SCSkuActivityVO scSkuActivityVO =  repository.querySCSkuActivityBySCGoodsId(source,channel,goodsId);
        if(null == scSkuActivityVO) return null;
        return repository.queryGroupBuyActivityDiscountVO(scSkuActivityVO.getActivityId());
    }
}
